## DESCRIPTION
## Differential calculus: linear approximation
## ENDDESCRIPTION

## KEYWORDS('differential calculus', 'linear approximation')

## DBsubject('WeBWorK')
## DBchapter('WeBWorK Tutorial')
## DBsection('Fort Lewis Tutorial 2011')
## Date('01/30/2011')
## Author('Paul Pearson')
## Institution('Fort Lewis College')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')


##############################
#  Initialization

DOCUMENT(); 

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"AnswerFormatHelp.pl",
"answerHints.pl",
"parserAssignment.pl",
);

TEXT(beginproblem());


#############################
#  Setup

Context("Numeric")->variables->add(y=>"Real");
parser::Assignment->Allow;

$a = random(2,5,1);
$aa = $a**2;
$a2 = 2 * $a;

$f = Compute("sqrt(x)");

$answer = Compute("y = $a + (1/$a2) * (x-$aa)");


#############################
#  Main text

Context()->texStrings;
BEGIN_TEXT
Find the linear approximation to \( f(x) = $f \)
at \( x = $aa \).  Your answer should be an 
equation in the variables \( x \) and \( y \).
$BR
$BR
\{ ans_rule(20) \}
\{ AnswerFormatHelp("equations") \}
END_TEXT
Context()->normalStrings;


############################
#  Answers

$showPartialCorrectAnswers = 1;

ANS( $answer->cmp() 
->withPostFilter(AnswerHints( 
  [Formula("1/$a2"),Formula("y=1/$a2")] => 
  ["Your answer should be an equation for a non-horizontal line.",
  replaceMessage=>1],
))
);


############################
#  Solution

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT("MathObject version.");

ENDDOCUMENT();

